import * as echarts from 'echarts/core';
/**
 * 数据分析 人员数据分析（政治面貌分布）——横向柱状图
 * 
 * **/
let timer = null;
const indexEchartsPie2 = (data, myChart) => {
    let trafficWay = [
        { name: '群众', value: 24, },
        { name: '团员', value: 18, },
        { name: '党员', value: 29, },
    ];
    let color = ['#0CF1EC', '#FFE244', '#1EDAA7'];
    let seriesOption = [
        {
            name: '',
            type: 'pie',
            radius: '65%',
            center: ['20%', '50%'],
            roseType: true,
            label: {
                show: false,
                position: "center",
            },
            hoverAnimation: false,
            data: trafficWay,
        },

    ];

    const defaultConfig = {
        color: color,

        tooltip: {
            show: true,
            trigger: 'item',
            formatter: '{b}: {c}人 ({d}%)',
            backgroundColor: 'rgba(3, 9, 24,1)',
            textStyle: {
                color: 'rgba(255, 255, 255, 1)'
            }
        },

        legend: {
            top: "center",
            right: "10%",
            orient: "vertical", //改变排列方式
            icon: "roundRect", //改变legend小图标形状
            itemGap: 20, // 设置legend的间距
            itemWidth: 20, // 设置宽度
            itemHeight: 15, // 设置高度
            formatter: function (name) {
                console.log(trafficWay.length, "trafficWay.length")
                for (let i = 0; i < trafficWay.length; i++) {
                    if (name === trafficWay[i].name) {
                        return `{name|${name}}{value${i}|${trafficWay[i].value}人}`;
                    }
                }
            },
            textStyle: {
                rich: {
                    name: {
                        fontSize: 12,
                        fontWeight: 400,
                        width: 70,
                        color: '#fff',
                    },
                    rate: {
                        fontSize: 12,
                        color: '#fff',
                    },
                    value0: {
                        fontSize: 15,
                        fontWeight: 500,
                        width: 50,
                        padding: [-5, 0, 0, ],
                        color: "#0CF1EC",
                        fontFamily: 'PangMenZhengDao',
                    },
                    value1: {
                        fontSize: 15,
                        fontWeight: 500,
                        width: 50,
                        color: "#FFE244",
                        padding: [-5, 0, 0, ],
                        fontFamily: 'PangMenZhengDao',
                    },
                    value2: {
                        fontSize: 15,
                        fontWeight: 500,
                        width: 50, padding: [-5, 0, 0, ],
                        color: "#1EDAA7",
                        fontFamily: 'PangMenZhengDao',
                    }
                }
            },
        },
        series: seriesOption,
    }

    const opt = { ...defaultConfig };
    return opt;
};

export default {
    indexEchartsPie2
}

